/**
 * @a https://leetcode.cn/problems/find-the-index-of-the-first-occurrence-in-a-string/description/
 */

#include "common.h"
class Solution {
public:
    int strStr(string haystack, string needle) {
        int cur1 = 0,cur2 = 0;
        int sz1 = haystack.size(), sz2 = needle.size();
        if(sz1 < sz2) return -1;
        for(int i = 0; i <= sz1 - sz2; ++i){
            int j,k;
            j = k = 0;
            while(k < sz2 && haystack[i+j] == needle[k]){
                ++j;++k;
            }
            if(k == sz2) return i;
        }
        return -1;
    }
};